// import axios from 'axios'
//需要拦截器的地方使用instance对象， 有自定义返回逻辑的地方沿用axios，在组件内部处理返回结果即可
import instance from './filter'
import instance10 from './filterlong'
const http = "/api"; 

//获取token
export const getToken = (name: string, password: string) => {
    return instance.get(http + "/Login/GetToken?name=" + name + "&password=" + password);
}

//菜单模块
//获取列表
export const getMenuDataNew = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Menu/GetMenus", prams)
}
//添加
export const addMenu = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Menu/Add", prams)
}
//修改
export const editMenu = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Menu/Edit", prams)
}
//删除
export const delMenu = async (id: number) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Menu/Del?id=" + id)
}
//BatchDel
export const batchDelMenu = async (ids: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Menu/BatchDel?ids=" + ids)
}
//分配菜单
export const settingMenu = async (rid: string,mids: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(`${http}/Menu/SettingMenu?rid=${rid}&mids=${mids}`)
}
//角色模块
//获取列表
export const getRoleData = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Role/GetRoles", prams)
}
//添加
export const addRole = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Role/Add", prams)
}
//修改
export const editRole = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Role/Edit", prams)
}
//删除
export const delRole = async (id: number) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Role/Del?id=" + id)
}
//BatchDel
export const batchDelRole = async (ids: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Role/BatchDel?ids=" + ids)
}

//用户模块
//获取列表
export const getUserData = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Users/GetUsers", prams)
}
//添加
export const addUsers = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Users/Add", prams)
}
//修改
export const editUsers = async (prams: {}) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.post(http + "/Users/Edit", prams)
}
//删除
export const delUsers = async (id: number) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Users/Del?id=" + id)
}
//BatchDel
export const batchDelUsers = async (ids: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(http + "/Users/BatchDel?ids=" + ids)
}
//分配
export const settingRole = async (pid: string,rids: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(`${http}/Users/SettingRole?pid=${pid}&rids=${rids}`)
}
//根据角色获取菜单
export const getUserMenus = async () => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(`${http}/Menu/GetUserMenus`)
}
//个人中心修改用户昵称和密码
export const editNickNameOrPassword = async (nickName: string,password: string) => {
    instance.defaults.headers.common['Authorization'] = "Bearer " + localStorage["token"];
    return instance.get(`${http}/Users/EditNickNameOrPassword?nickName=${nickName}&password=${password}`)
}



//#region 任务列表处理
//获取任务列表
export const getJobList = async (jobid:string) => {
    return instance.post(`${http}/getjob/${jobid}`)
}
//修改任务
export const updateJob = async (prams: {}) => {
    return instance.post(http + "/update", prams)
}
//添加任务
export const addJob = async (prams: {}) => {
    return instance.post(http + "/add", prams)
}
//任务启停   /api/changesStatus/任务ID/0停止1启动
export const changesStatus = async (jobId:number,jobStatus:string) => {
    return instance.post(`${http}/changesStatus/${jobId}/${jobStatus}`)
}
//单次执行
export const onceJob = async (prams: {}) => {
    return instance10.post(http + "/once", prams)
}
//#endregion

//#region 数据库连接信息处理
export const GetDblist = async ()=>{
    return instance.post(http + "/GetDblist")
}
export const AddDblist = async (prams: {})=>{
    return instance.post(http + "/AddDatabase",prams)
}
export const UpdateDblist = async (prams: {})=>{
    return instance.post(http + "/UpdateDatabase",prams)
}
export const DatabaseTest = async (prams: {})=>{
    return instance.post(http + "/DatabaseTest",prams)
}
//#endregion


//#region 日志处理
export const getLog = async (current:number,size:number,str:string)=>{
    return instance.post(`${http}/getlog/ByPage?current=${current}&size=${size}&params=${str}`)
}
export const getLogmx = async (current:number,size:number,str:string,str2:string)=>{
    return instance.post(`${http}/getlogmx/ByPage?current=${current}&size=${size}&params=${str}&uuid=${str2}`)
}
//#endregion

//#region 字典对照处理
export const getDictList = async (current:number)=>{
    return instance.post(`${http}/getlog/ByPage?current=${current}&size=${size}&params=${str}`)
}
export const changeDictStatus = async (current:number)=>{
    return instance.post(`${http}/getlog/ByPage?current=${current}&size=${size}&params=${str}`)
}
export const deleteDict = async (current:number)=>{
    return instance.post(`${http}/getlog/ByPage?current=${current}&size=${size}&params=${str}`)
}
export const batchDeleteDict = async (current:number)=>{
    return instance.post(`${http}/getlog/ByPage?current=${current}&size=${size}&params=${str}`)
}
//#endregion
